package com.freesky.quartz.task;

import cn.hutool.core.date.DateUtil;
import com.freesky.biz.icbc.mapper.MarketingActivityDataMapper;
import com.freesky.common.core.redis.RedisCache;
import com.freesky.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 工行营销日历(统计）
 */
@Component("marketingActivityDataTask")
public class MarketingActivityDataTask {

    @Autowired
    private RedisCache redisCache;

    @Autowired
    private MarketingActivityDataMapper activityDataMapper;

    private String REPORT_MARKETING_KEY = "REPORT:DAY:MARKETING";

    public void taskProcess() {
        String minUpdateDate = "2024-09-05";
        String startDt = redisCache.getCacheObject(REPORT_MARKETING_KEY);
        if(StringUtils.isEmpty(startDt)){
            startDt = minUpdateDate;
        }
        activityDataMapper.addDayCount(startDt);
        String endDt = DateUtil.format(DateUtil.offsetDay(new Date(), -2),"yyyy-MM-dd");
        redisCache.setCacheObject(REPORT_MARKETING_KEY,endDt);

    }
}
